package com.zenchn.dynamic;

import static com.zenchn.dynamic.TMiAccountExtendDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TMiAccountExtend;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TMiAccountExtendDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    BasicColumn[] selectList = BasicColumn.columnList(accountId, accountLevel, areasCode, regionCode, agentTarget, agentL2Target, agentL3Target, hospitalTarget, hospitalL2Target, hospitalL3Target, wxOpenId);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TMiAccountExtend> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TMiAccountExtend> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TMiAccountExtendResult")
    Optional<TMiAccountExtend> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TMiAccountExtendResult", value = {
        @Result(column="account_id", property="accountId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="account_level", property="accountLevel", jdbcType=JdbcType.CHAR),
        @Result(column="areas_code", property="areasCode", jdbcType=JdbcType.CHAR),
        @Result(column="region_code", property="regionCode", jdbcType=JdbcType.CHAR),
        @Result(column="agent_target", property="agentTarget", jdbcType=JdbcType.INTEGER),
        @Result(column="agent_l2_target", property="agentL2Target", jdbcType=JdbcType.INTEGER),
        @Result(column="agent_l3_target", property="agentL3Target", jdbcType=JdbcType.INTEGER),
        @Result(column="hospital_target", property="hospitalTarget", jdbcType=JdbcType.INTEGER),
        @Result(column="hospital_l2_target", property="hospitalL2Target", jdbcType=JdbcType.INTEGER),
        @Result(column="hospital_l3_target", property="hospitalL3Target", jdbcType=JdbcType.INTEGER),
        @Result(column="wx_open_id", property="wxOpenId", jdbcType=JdbcType.VARCHAR)
    })
    List<TMiAccountExtend> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TMiAccountExtend, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TMiAccountExtend, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default int deleteByPrimaryKey(String accountId_) {
        return delete(c ->
            c.where(accountId, isEqualTo(accountId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default int insert(TMiAccountExtend record) {
        return MyBatis3Utils.insert(this::insert, record, TMiAccountExtend, c ->
            c.map(accountId).toProperty("accountId")
            .map(accountLevel).toProperty("accountLevel")
            .map(areasCode).toProperty("areasCode")
            .map(regionCode).toProperty("regionCode")
            .map(agentTarget).toProperty("agentTarget")
            .map(agentL2Target).toProperty("agentL2Target")
            .map(agentL3Target).toProperty("agentL3Target")
            .map(hospitalTarget).toProperty("hospitalTarget")
            .map(hospitalL2Target).toProperty("hospitalL2Target")
            .map(hospitalL3Target).toProperty("hospitalL3Target")
            .map(wxOpenId).toProperty("wxOpenId")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default int insertMultiple(Collection<TMiAccountExtend> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TMiAccountExtend, c ->
            c.map(accountId).toProperty("accountId")
            .map(accountLevel).toProperty("accountLevel")
            .map(areasCode).toProperty("areasCode")
            .map(regionCode).toProperty("regionCode")
            .map(agentTarget).toProperty("agentTarget")
            .map(agentL2Target).toProperty("agentL2Target")
            .map(agentL3Target).toProperty("agentL3Target")
            .map(hospitalTarget).toProperty("hospitalTarget")
            .map(hospitalL2Target).toProperty("hospitalL2Target")
            .map(hospitalL3Target).toProperty("hospitalL3Target")
            .map(wxOpenId).toProperty("wxOpenId")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default int insertSelective(TMiAccountExtend record) {
        return MyBatis3Utils.insert(this::insert, record, TMiAccountExtend, c ->
            c.map(accountId).toPropertyWhenPresent("accountId", record::getAccountId)
            .map(accountLevel).toPropertyWhenPresent("accountLevel", record::getAccountLevel)
            .map(areasCode).toPropertyWhenPresent("areasCode", record::getAreasCode)
            .map(regionCode).toPropertyWhenPresent("regionCode", record::getRegionCode)
            .map(agentTarget).toPropertyWhenPresent("agentTarget", record::getAgentTarget)
            .map(agentL2Target).toPropertyWhenPresent("agentL2Target", record::getAgentL2Target)
            .map(agentL3Target).toPropertyWhenPresent("agentL3Target", record::getAgentL3Target)
            .map(hospitalTarget).toPropertyWhenPresent("hospitalTarget", record::getHospitalTarget)
            .map(hospitalL2Target).toPropertyWhenPresent("hospitalL2Target", record::getHospitalL2Target)
            .map(hospitalL3Target).toPropertyWhenPresent("hospitalL3Target", record::getHospitalL3Target)
            .map(wxOpenId).toPropertyWhenPresent("wxOpenId", record::getWxOpenId)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default Optional<TMiAccountExtend> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TMiAccountExtend, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default List<TMiAccountExtend> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TMiAccountExtend, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default List<TMiAccountExtend> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TMiAccountExtend, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default Optional<TMiAccountExtend> selectByPrimaryKey(String accountId_) {
        return selectOne(c ->
            c.where(accountId, isEqualTo(accountId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TMiAccountExtend, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    static UpdateDSL<UpdateModel> updateAllColumns(TMiAccountExtend record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(accountId).equalTo(record::getAccountId)
                .set(accountLevel).equalTo(record::getAccountLevel)
                .set(areasCode).equalTo(record::getAreasCode)
                .set(regionCode).equalTo(record::getRegionCode)
                .set(agentTarget).equalTo(record::getAgentTarget)
                .set(agentL2Target).equalTo(record::getAgentL2Target)
                .set(agentL3Target).equalTo(record::getAgentL3Target)
                .set(hospitalTarget).equalTo(record::getHospitalTarget)
                .set(hospitalL2Target).equalTo(record::getHospitalL2Target)
                .set(hospitalL3Target).equalTo(record::getHospitalL3Target)
                .set(wxOpenId).equalTo(record::getWxOpenId);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TMiAccountExtend record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(accountId).equalToWhenPresent(record::getAccountId)
                .set(accountLevel).equalToWhenPresent(record::getAccountLevel)
                .set(areasCode).equalToWhenPresent(record::getAreasCode)
                .set(regionCode).equalToWhenPresent(record::getRegionCode)
                .set(agentTarget).equalToWhenPresent(record::getAgentTarget)
                .set(agentL2Target).equalToWhenPresent(record::getAgentL2Target)
                .set(agentL3Target).equalToWhenPresent(record::getAgentL3Target)
                .set(hospitalTarget).equalToWhenPresent(record::getHospitalTarget)
                .set(hospitalL2Target).equalToWhenPresent(record::getHospitalL2Target)
                .set(hospitalL3Target).equalToWhenPresent(record::getHospitalL3Target)
                .set(wxOpenId).equalToWhenPresent(record::getWxOpenId);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default int updateByPrimaryKey(TMiAccountExtend record) {
        return update(c ->
            c.set(accountLevel).equalTo(record::getAccountLevel)
            .set(areasCode).equalTo(record::getAreasCode)
            .set(regionCode).equalTo(record::getRegionCode)
            .set(agentTarget).equalTo(record::getAgentTarget)
            .set(agentL2Target).equalTo(record::getAgentL2Target)
            .set(agentL3Target).equalTo(record::getAgentL3Target)
            .set(hospitalTarget).equalTo(record::getHospitalTarget)
            .set(hospitalL2Target).equalTo(record::getHospitalL2Target)
            .set(hospitalL3Target).equalTo(record::getHospitalL3Target)
            .set(wxOpenId).equalTo(record::getWxOpenId)
            .where(accountId, isEqualTo(record::getAccountId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_account_extend")
    default int updateByPrimaryKeySelective(TMiAccountExtend record) {
        return update(c ->
            c.set(accountLevel).equalToWhenPresent(record::getAccountLevel)
            .set(areasCode).equalToWhenPresent(record::getAreasCode)
            .set(regionCode).equalToWhenPresent(record::getRegionCode)
            .set(agentTarget).equalToWhenPresent(record::getAgentTarget)
            .set(agentL2Target).equalToWhenPresent(record::getAgentL2Target)
            .set(agentL3Target).equalToWhenPresent(record::getAgentL3Target)
            .set(hospitalTarget).equalToWhenPresent(record::getHospitalTarget)
            .set(hospitalL2Target).equalToWhenPresent(record::getHospitalL2Target)
            .set(hospitalL3Target).equalToWhenPresent(record::getHospitalL3Target)
            .set(wxOpenId).equalToWhenPresent(record::getWxOpenId)
            .where(accountId, isEqualTo(record::getAccountId))
        );
    }
}
